/*
 * UMediaEventName.cpp
 *
 *  Created on: 2020年3月15日
 *      Author: chuanjiang.zh
 */

#include "UMediaEventName.h"


struct EventNamePair
{
    int event;
    const char* name;
};

static EventNamePair s_eventNames[] =
{
    {UMEDIA_EVENT_OPENING, "opening"},
	{UMEDIA_EVENT_OPEN_FAILED, "failed"},
	{UMEDIA_EVENT_OPENED, "opened"},
	{UMEDIA_EVENT_CLOSED, "closed"},
	{UMEDIA_EVENT_END, "end"},
	{UMEDIA_EVENT_FORMAT_READY, "format_ready"},
	{UMEDIA_EVENT_SEEKING, "seeking"},
	{UMEDIA_EVENT_SEEKED, "seeked"},

	{UMEDIA_EVENT_FULLSCREEN, "fullscreen"},
	{UMEDIA_EVENT_VOLUME, "volume"},
	{UMEDIA_EVENT_MUTE, "mute"},
	{UMEDIA_EVENT_SCALE, "scale"},

	{UMEDIA_EVENT_PLAYING, "playing"},
	{UMEDIA_EVENT_PAUSED, "paused"},
	{UMEDIA_EVENT_STOPPED, "stopped"},

	{UMEDIA_EVENT_PACKET, "packet"},

	{UMEDIA_EVENT_SNAPPED, "snapped"},
	{UMEDIA_EVENT_CONNECTED, "connected"},
	{UMEDIA_EVENT_DISCONNECTED, "disconnected"},

	{ UMEDIA_EVENT_CACHE, "cache" },
	{ UMEDIA_EVENT_CACHE_EMPTY, "cache_empty" },
	{ UMEDIA_EVENT_CACHE_FULL, "cache_full" },

	{UMEDIA_EVENT_CREATED, "created"},
	{UMEDIA_EVENT_DESTROYED, "destroyed"},
	{UMEDIA_EVENT_REOPEN, "reopen"},
	{UMEDIA_EVENT_INTR, "intr"}

};

const char* UMediaEventName::toString(UMediaEventType t)
{
    size_t count = sizeof(s_eventNames)/sizeof(s_eventNames[0]);
    for (size_t i = 0; i < count; i ++)
    {
        if (t == s_eventNames[i].event)
        {
            return s_eventNames[i].name;
        }
    }
    return "";
}
